package com.cxz.spring.v2.controller;

import com.cxz.spring.v2.annotation.CxzAutowired;
import com.cxz.spring.v2.annotation.CxzController;
import com.cxz.spring.v2.annotation.CxzRequestMapping;
import com.cxz.spring.v2.annotation.CxzRequestParam;
import com.cxz.spring.v2.service.DemoService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author cxz
 * @version V1.0
 * @Date 2022/9/7 17:36
 * @desc
 */
@CxzController
@CxzRequestMapping("/demo")
public class DemoController {

    @CxzAutowired
    private DemoService demoService;

    @CxzRequestMapping("/query")
    public void  query(HttpServletRequest req, HttpServletResponse resp, @CxzRequestParam("name") String name) {
        String result = demoService.get(name);

        try {
            resp.getWriter().write(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
